package cn.tjd.jwttest.service.impl;

import cn.tjd.jwttest.mapper.UserMapper;
import cn.tjd.jwttest.pojo.User;
import cn.tjd.jwttest.service.UserService;
import cn.tjd.jwttest.utils.TokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Auther: TJD
 * @Date: 2020-02-02
 * @DESCRIPTION:
 **/
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public String login(String userCode, String pwd) {
        User user = userMapper.login(userCode, pwd);
        String token = null;
        if (user != null) {
            token = TokenUtils.createJWT(300000, user);
        }
        return token;
    }
}
